*** Settings ***
Test Setup        common_test_setup    @{crm_consignormanage_menu}
Test Teardown     Run Keyword If Test Failed    common_test_teardown
Resource          ../../resource/workflow.txt
Resource          ../../resource/custommanage/consignormanage.txt
Resource          ../../testdata/${testenv}/custommanage/consignormanage.txt

*** Test Cases ***
consignor_modify
    kw_crm_consignor_search    nameorphoneinput=@{crm_consignor_modify}[1]
    kw_crm_consignor_modify    @{crm_consignor_modify}[0]    add=@{crm_consignor_modify}[2]    expectedmsg=@{crm_consignor_modify}[3]
    kw_crm_consignor_search    nameorphoneinput=@{crm_consignor_modify}[1]
    common_first_row_operate    ${False}    编辑
    wait page loaded
    ${value}    Get Element Attribute New    ${loc_crm_add_value}    innerHTML
    ${tmp_v}    evaluate    "${value}".strip().replace('/',',').replace(' ','')
    Should Be Equal    ${tmp_v}    @{crm_consignor_modify}[2]
    click element new    ${loc_crm_close}
    wait_modal_invisible

consignor_playback
    kw_crm_consignor_search    nameorphoneinput=@{crm_consignor_playback}[0]
    ${count}    Get Table Element Text    1    13
    @{l}    evaluate    list(@{crm_consignor_playback})[2:]
    kw_crm_consignor_playback    @{l}
    ${count2}    Get Table Element Text    1    13
    ${new_playback}    Get Table Element Text    1    14
    run keyword if    not "${count}".strip()    Should Contain    ${new_playback}    @{crm_consignor_playback}[1]
    ${count2-1}    evaluate    ${count2}-1
    Should Be Equal As Integers    ${count}    ${count2-1}

consignor_eliminate
    kw_crm_consignor_search    nameorphoneinput=@{crm_consignor_eliminate}[0]
    @{l}    evaluate    list(@{crm_consignor_eliminate})[2:]
    kw_crm_consignor_eliminate    @{l}
    ${tmp_bol}    is_table_result_empty    2
    Should Be True    ${tmp_bol}
    select_tabs_bar    已淘汰
    ${resultnum2}    get_table_result_count
    Should Be Equal As Integers    ${resultnum2}    1
    common_first_row_operate    ${False}    淘汰原因
    Element Text Should Be New    ${loc_crm_close_reason_text}    @{crm_consignor_eliminate}[1]
    click element new    ${loc_common_close}
    wait_modal_invisible

consignor_eliminate_recover
    Depends On Test Success    consignor_eliminate
    kw_crm_consignor_search    nameorphoneinput=@{crm_consignor_eliminate}[0]
    kw_crm_consignor_eliminate_recover
    ${tmp_bol}    is_table_result_empty    2
    Should Be True    ${tmp_bol}
    select_tabs_bar    @{crm_consignor_eliminate}[2]
    ${resultnum2}    get_table_result_count
    Should Be Equal As Integers    ${resultnum2}    1

consignor_sign
    kw_crm_consignor_search    nameorphoneinput=@{crm_consignor_sign}[0]
    ${filepath}    catenate    SEPARATOR=\\    ${EXECDIR}    testdata    ${testenv}    testload.xlsx
    @{l}    evaluate    list(@{crm_consignor_sign})[1:]
    kw_crm_consignor_sign    ${filepath}    ${filepath}    ${filepath}    @{l}
    comment    需要去走审批流程
    @{rs}    Query    SELECT contract_number FROM crm.`contract` t1 join crm.customer_info t2 on t2.customer_id = t1.customer_id WHERE t1.contract_name = 'autotest_货主_签约' and t1.contract_status = 2;
    Click Menu Into Page    @{workflow_menu}
    kw_workflow_approve    @{rs}[-1]    同意    双手赞成    同意    双手赞成
    Click Menu Into Page    @{crm_consignormanage_menu}
    comment    需要去走审批流程

consignor_file
    [Tags]    notrun
    kw_crm_consignor_search    nameorphoneinput=@{crm_consignor_file}[0]
    ${filepath}    catenate    SEPARATOR=\\    ${EXECDIR}    testdata    ${testenv}    testload.xlsx
    ${date}=    Get Current Date    result_format=%Y-%m-%d
    kw_crm_consignor_file    @{crm_consignor_file}[1]    ${date}    ${filepath}    @{crm_consignor_file}[3]
    comment    需要去合同中检查归档状态
